package com.blb.thread.homework;

import java.io.*;

public class Homework2 {

    public static void main(String[] args) {
        //扫描文本文件
        new Thread(() -> {
            //扫描某个目录
            File dir = new File("D:\\作业\\2html\\2组html\\2组html\\郭广源\\郭广源");
            //筛选特定文件
            File[] files = dir.listFiles(((dir1, name) -> name.endsWith(".java") || name.endsWith(".txt") || name.endsWith(".html")));
            //打印文件内容
            for(File file : files){
                try (BufferedReader reader = new BufferedReader(new FileReader(file))){
                    String line = null;
                    while((line = reader.readLine()) != null){
                        System.out.println(line);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
